package com.lgb.controller;

import com.lgb.Service.PicturesService;
import com.lgb.vo.PicturesQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PicturesShowController {

    @Autowired
    private PicturesService picturesService;

    @RequestMapping("/pictures")
    public String pictures(Model model){
        //将数据传递给前端
        model.addAttribute("pictures" , picturesService.getAllPicturesQuery());
        return "pictures";
    }

    @GetMapping("/show_picture/{id}")
    public String picture_show(@PathVariable Long id , Model model){
        //获取图片集合
        PicturesQuery picturesQuery = picturesService.getPictureQuery(id);
        model.addAttribute("picturequery" , picturesQuery);
        return "/picture";
    }
}
